package org.gl.ui.manger;

import java.io.File;

import net.tsz.afinal.FinalActivity;
import net.tsz.afinal.annotation.view.ViewInject;

import org.gl.GlobalVariable;
import org.gl.android.base.R;
import org.gl.utils.Tip;

import android.os.Bundle;
import android.os.Environment;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.TextView;

import com.nostra13.universalimageloader.core.ImageLoader;

public class BaseActivity extends FinalActivity implements OnClickListener {
	public static String TAG;
	public final String URI_SDCARD_ROOTPATH = "file://"+Environment.getExternalStorageDirectory().getPath();
	public final String UriSDcard = URI_SDCARD_ROOTPATH + GlobalVariable.AppDir
			+ File.separator;
	public final String UriAsset = "assets://";
	protected ImageLoader imageLoader = ImageLoader.getInstance();
	@ViewInject(id = 0, click = "onClick")
	TextView textView;

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		getMenuInflater().inflate(R.menu.main_menu, menu);
		return true;
	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		if (item.getItemId() == R.id.item_clear_memory_cache) {
			imageLoader.clearMemoryCache();
			return true;
		} else if (R.id.item_clear_disc_cache == item.getItemId()) {
			imageLoader.clearDiscCache();
			return true;
		}
		return false;
	}

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		TAG = this.getClass().getSimpleName();
		TextView tv = new TextView(this);
		tv.setText("baseActivtiy");
		tv.setId(0);
		setContentView(tv);
	}

	@Override
	public void onClick(View v) {
		Tip.show("onclick"+v.getId());
	}
}
